import { request } from '@/utils/request.js'

// 获取用户地址列表
export function getUserAddresses() {
	return request({
		url: '/api/address',
		method: 'GET'
	})
}

// 获取地址详情
export function getAddressDetail(id) {
	return request({
		url: `/api/address/${id}`,
		method: 'GET'
	})
}

// 创建地址
export function createAddress(data) {
	return request({
		url: '/api/address',
		method: 'POST',
		data
	})
}

// 更新地址
export function updateAddress(id, data) {
	return request({
		url: `/api/address/${id}`,
		method: 'PUT',
		data
	})
}

// 删除地址
export function deleteAddress(id) {
	return request({
		url: `/api/address/${id}`,
		method: 'DELETE'
	})
}

// 设置默认地址
export function setDefaultAddress(id) {
	return request({
		url: `/api/address/${id}/default`,
		method: 'PUT'
	})
}

// 获取默认地址
export function getDefaultAddress() {
	return request({
		url: '/api/address/default',
		method: 'GET'
	})
}